package com.ecoolex.hotel.saas.platform.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;

import com.ecoolex.framework.modularize.api.auth.AuthorityRegister;
import com.ecoolex.framework.modularize.api.auth.admin.AdminMemberAuthorityManager;
import com.ecoolex.framework.modularize.api.auth.platform.PlatformMemberAuthorityManager;
import com.ecoolex.framework.modularize.api.auth.user.ConsumerMemberAuthorityManager;
import com.ecoolex.framework.modularize.api.auth.AuthorityRegister;
import com.ecoolex.framework.modularize.api.service.config.SystemConfig;
import com.ecoolex.hotel.saas.Constant;
import com.ecoolex.hotel.saas.platform.core.PlatformConstant;

@Profile(PlatformConstant.PROJECT_PLATFORM_NAME)
@Configuration
public class HotelSaasPlatformInitializer {

	/**
	 * 系统配置注册
	 * @param config
	 */
	@Autowired
	public void registerSystemConfig(SystemConfig config) {
//		config.register(PlatformConstant.CONFIG_ENABLE_USER_REGISTER, "true", "启用用户注册页面", PlatformConstant.PROJECT_PLATFORM_NAME);
	}

	/**
	 * 权限注册
	 */
	@Autowired
	public void registerUserAuth(PlatformMemberAuthorityManager authorityManager) {
		// 子项目模块注册
		AuthorityRegister register = new AuthorityRegister();
//		register.setParentKey(Constant.AUTH_MODULE_KEY);
		register.setKey(PlatformConstant.AUTH_PROJECT_KEY);
		register.setName(PlatformConstant.AUTH_PROJECT_NAME);
		register.setRemark(PlatformConstant.AUTH_PROJECT_REMARK);
	
		authorityManager.register(register);
	}
}
